template.defaults.imports.TimestampToTime = function (timestamp) {
    var date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
    var Y = date.getFullYear() + '-';
    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    var D = date.getDate() + ' ';
    var h = date.getHours() + ':';
    var m = date.getMinutes() + ':';
    var s = date.getSeconds();
    return Y + M + D + h + m + s;
};



    var loading = false; //状态标记
    var hasNextPage = false;
    var pageNo = 1;
    var querytype = 1;
    queryList(pageNo);

    //下拉刷新
    $("#aroundBox").pullToRefresh().on("pull-to-refresh", function () {
        $("#contentTo").html("");
        pageNo = 1;
        queryList(pageNo,function(){
            $("#aroundBox").pullToRefreshDone(); // 重置下拉刷新
        });
    });
  
    //上拉加载更多
    $('#aroundBox').infinite().on("infinite", function () {
        if (hasNextPage){
            pageNo++;
            queryList(pageNo,function(){
            },true);
        }        
    });

    function queryList(pageNo,callback,isMore){
        if (loading) return;
        loading = true;
        var params = {};
        params.start = (pageNo - 1) * 20;
        params.limit = 20;
         /* global getCookie */
         /* global querytype */
        params.token = getCookie('token');
        params.queryType = querytype;

        $.get('/antique/api/mallOrderEvaluate/query_evaluate_list', params, function (result) {
            if (result.code == 0) {
                hasNextPage = result.data.hasNextPage;
                if (!isMore){
                    /* global template */
                    console.log(result);
                    document.getElementById('contentTo').innerHTML = template('content', result.data);                
                } else {
                    $("#contentTo").append(template('content', result.data));
                }
                $('.eva1').raty({ readOnly: true, score: 3 });
                if (!result.data.hasNextPage) {
                    $('#loadmore').hide();
                    $('#nomore').show();
                } else {
                    $('#loadmore').show();
                    $('#nomore').hide();
                }
                if (callback) callback();
                loading = false;
            }            
        });
    }
$(".weui-tab .tabs .item").click(function () {
        $(".weui-tab .tabs .item").removeClass("current");
        $(this).addClass("current");
    
        querytype = $(this).data('querytype');
        $("#contentTo").html("");
        pageNo = 1;
        queryList(pageNo,function(){
            $("#aroundBox").pullToRefreshDone(); // 重置下拉刷新
        });
        
    });
